package com.xayy.ds.controller;

import com.xtck.ha.common.core.constant.HttpStatus;
import com.xtck.ha.common.core.utils.poi.ExcelUtil;
import com.xtck.ha.common.core.web.controller.BaseController;
import com.xtck.ha.common.core.web.domain.AjaxResult;
import com.xtck.ha.common.core.web.page.TableDataInfo;
import com.xayy.ds.model.DsDataInfo;
import com.xayy.ds.service.DsDataInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 模型列表 controller
 *
 * @ClassName: DsDataInfoController
 * @Description: 外部访问接口
 * @author liuyuan
 * @date 2025-07-03
 */
@Api(tags = "数据信息表管理")
@RestController
@RequestMapping("/api/v1.0/dataInfo")
public class DsDataInfoController extends BaseController {

    @Autowired
    private DsDataInfoService dsDataInfoService;


    @ApiOperation("分页查询数据信息表列表")
    @GetMapping("/page")
    public AjaxResult page(DsDataInfo dsDataInfo)
    {
        startPage();
        List<DsDataInfo> list = dsDataInfoService.selectTList(dsDataInfo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setList(list);
        rspData.setMsg("查询成功");
        rspData.setTotal(dsDataInfoService.count(dsDataInfo));
        return AjaxResult.success(rspData);
    }

    @ApiOperation("列表查询数据信息表")
    @GetMapping("/list")
    public AjaxResult list(DsDataInfo dsDataInfo)
    {
        List<DsDataInfo> list = dsDataInfoService.selectTList(dsDataInfo);
        return AjaxResult.success(list);
    }

    @ApiOperation("导出数据信息表列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsDataInfo dsDataInfo)
    {
        List<DsDataInfo> list = dsDataInfoService.selectTList(dsDataInfo);
        ExcelUtil<DsDataInfo> util = new ExcelUtil<>(DsDataInfo.class);
        util.exportExcel(response, list, "样例数据");
    }

    @ApiOperation("获取$数据信息表详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dsDataInfoService.selectTById(id));
    }

    @ApiOperation("新增$数据信息表")
    @PostMapping({"/save"})
    public AjaxResult add(@RequestBody DsDataInfo dsDataInfo)
    {
        return toAjax(dsDataInfoService.insertT(dsDataInfo));
    }

    @ApiOperation("修改数据信息表")
    @PutMapping({"/update"})
    public AjaxResult update(@RequestBody DsDataInfo dsDataInfo)
    {
        int i = dsDataInfoService.updateT(dsDataInfo);
        return toAjax(i);
    }

    @ApiOperation("删除数据信息表")
	@DeleteMapping({"/delete"})
    public AjaxResult remove(@RequestBody List<Long> idList)
    {
        return toAjax(dsDataInfoService.deleteTByIds(idList.toArray(new Long[0])));
    }





}
